<template>
  <div>
    <h1>登录页面</h1>
    <table class="table table-bordered">
      <tbody>
        <tr>
          <td>用户名</td>
          <td><input type="text" v-model="state.name"/></td>
        </tr>
        <tr>
          <td>密码</td>
          <td><input type="password" v-model="state.pwd"/></td>
        </tr>
        <tr>
          <td></td>
          <td><button  @click="ok">登录</button></td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { reactive, toRefs, onMounted } from 'vue';
import { useRouter, useRoute } from 'vue-router';

const route = useRoute();
const router = useRouter();

let data=reactive({
  state:{
    name:'',
    pwd:''
  }
})
let {state}=toRefs(data);

const ok = () => {
  axios.get('https://localhost:7075/api/User/Lohin?name=admin&pwd=admin',{
    params:{
      name:state.value.name,
      pwd:state.value.pwd
    }
    }
  )
  .then((res)=>{
    console.log(res);
    if(res.data.data==1){
     alert('登录成功');
    }
    else{
      alert('登录失败');
    }
  })
  .catch((err)=>{
    console.log(err);
  })
}





</script>

<style scoped></style>
